package org.mili.ticketeer.dao;

import org.mili.ticketeer.dto.Contact;
import org.mili.ticketeer.dto.Meeting;
import org.mili.ticketeer.util.Lambda;

import java.sql.SQLException;

public class MeetingDao extends AbstractDao {

    public MeetingDao() {
        super(Meeting.Fields.values(), Meeting.Fields.values(), Meeting.TABLE);
    }

    public Boolean assign(final Contact contact, final int date) throws DaoException {
        return doInDao(new Lambda<Boolean>() {
            @Override
            public Boolean exec(Object... params) throws SQLException {
                return update("insert into `meeting` (`contact`, `date`) values(?, ?);", contact.getId(), date) == 1;
            }
        });
    }
}
